package ar.com.spsolutions.splilabrary.view.pages.author;

import org.apache.wicket.spring.injection.annot.SpringBean;

import ar.com.spsolutions.splibrary.author.Author;
import ar.com.spsolutions.splibrary.general.RoleConverterService.RolesEnum;
import ar.com.spsolutions.splibrary.services.dto.AbstractCRUDDTO;
import ar.com.spsolutions.splibrary.services.dto.CRUDAuthorDTO;
import ar.com.spsolutions.splilabrary.view.components.CRUDComponent;
import ar.com.spsolutions.splilabrary.view.version2.components.MainContainer;

public class AuthorEditorComponent extends MainContainer {

	private static final long serialVersionUID = -4109231097254041246L;

	@SpringBean
	private CRUDAuthorDTO crudAuthorDTO;

	@Override
	protected void addComponents() {
		final CRUDComponent<Author> crudComponent = new CRUDComponent<Author>(
				"authorCRUD", "header", "footer", "data",
				this.getCrudAuthorDTO(), new String[] { "name:true" });
		crudComponent.addText("name", "nameLabel", RolesEnum.ROLE_LIBRARIAN);
		this.add(crudComponent);
	}

	private AbstractCRUDDTO<Author> getCrudAuthorDTO() {
		return this.crudAuthorDTO;

	}

	public void setCrudAuthorDTO(final CRUDAuthorDTO crudAuthorDTO) {
		this.crudAuthorDTO = crudAuthorDTO;
	}

}